//
//  MyInfosViewController.m
//  KuWeiPark
//
//  Created by Kevin Su on 15/5/11.
//  Copyright (c) 2015年 Clief. All rights reserved.
//

#import "MyInfosViewController.h"
#import "MyCarsListViewController.h"
#import "AppMacro.h"

@interface MyInfosViewController ()<UIActionSheetDelegate, UITextFieldDelegate>

@end

@implementation MyInfosViewController{
    
    MyCarsListViewController *myCarsListViewController;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    NSString *mainCarNumber = self.loginModel.carNumber;
    if(VALID_STRING(mainCarNumber).length == 0){
        
        self.mainCarNumLabel.text = @"未设置主车牌";
    }else{
        
        self.mainCarNumLabel.text = [NSString stringWithFormat:@"%@ (主车牌)", VALID_STRING(mainCarNumber)];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - IBActions

- (IBAction)back:(id)sender {
    
    [self hideKeyBoard];
    
    [self.navigationController popViewControllerAnimated:YES];
}

- (IBAction)setSexAction:(id)sender {
    
    [self hideKeyBoard];
    
    //选择性别
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"请选择性别" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"男", @"女", nil];
    [actionSheet showInView:self.view];
}

- (IBAction)showMyCarsAction:(id)sender {
    
    [self hideKeyBoard];
    
    //查看我的车牌列表
    myCarsListViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"MyCarsListViewController"];
    [self.navigationController pushViewController:myCarsListViewController animated:YES];
}

#pragma mark - ActionSheetDelegate
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    
    if(buttonIndex == 0){
        
        self.sexLabel.text = @"男";
    }else if(buttonIndex == 1){
        
        self.sexLabel.text = @"女";
    }
}

#pragma mark - UITextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    
    [self hideKeyBoard];
    return YES;
}


- (void)hideKeyBoard{
    
    [self.nameTextField resignFirstResponder];
}

@end
